from pydantic import BaseModel, Field
from typing import List, Dict, Set


class Question(BaseModel):
    id: int
    type: str
    content: str
    answer: str = '?'


class Exam(BaseModel):
    id: int
    title: str
    questions: List[Question] = Field(default_factory=list)


class ExamCollection(BaseModel):
    exams: List[Exam] = Field(default_factory=list)


class Answer(BaseModel):
    exam_id: int
    question_id: int
    options: Set[str] = Field(default_factory=set)
    correct: bool = False
    token_cost: int = 0
    messages: List[Dict[str, str]] = Field(default_factory=list)


class ExamResult(BaseModel):
    exam_id: int
    answers: Dict[int, Answer] = Field(default_factory=dict)


class ExamResultCollection(BaseModel):
    results: Dict[int, ExamResult] = Field(default_factory=dict)


class UnsupportedQuestion(Exception):
    pass